home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / SDKs / Word Services SDK 1.0.6 / Writeswell Jr 1.2.1 Sources ƒ / Writeswell Jr. Source / Options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-11  |  2.4 KB  |  100 lines  |  [TEXT/MMCC]

  1. /* Options.c
  2.  * Handle options dialog for Writeswell Jr.
  3.  * ©1992 Working Software, Inc.
  4.  * This source code is copyrighted.  Permission is granted to use the Word Services
  5.  * portion of the Writeswell Jr. source code in your own programs, but you 
  6.  * may not distribute the Writeswell Jr. word-processor code as a 
  7.  * commercial product.  If you modify the code, please do not call it 
  8.  * Writeswell Jr. (or Writeswell.)  This will ensure that people understand the 
  9.  * program and don’t have to deal with a number of different versions with 
  10.  * who-knows-what going on in the code.
  11.  * 
  12.  * Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
  13.  * 18 Aug 92 Mike Crawford
  14.  */
  15.  
  16. #include "TBConstants.h"
  17. #include "TBGlobals.h"
  18. #include "OutlineButton.h"
  19. #include "Options.h"
  20. #include "Prefs.h"
  21. #include "Gripe.h"
  22.  
  23. void OptionsDialog( void )
  24. {
  25.     DialogPtr    optDlg;
  26.     short        item;
  27.     short        kind;
  28.     Handle        h;
  29.     Rect        r;
  30.     Boolean        sendByList;
  31.     ControlHandle    listHdl;
  32.     ControlHandle    tblHdl;
  33.     WWJrPrefsHdl    prefHdl;
  34.     UserItemUPP        outlineUPP;
  35.     
  36.     prefHdl = GetPrefHandle();
  37.     if ( !prefHdl ){
  38.         Gripe( "\pCannot get preferences handle" );
  39.         return;
  40.     }
  41.             
  42.     optDlg = GetNewDialog( rOptionsID, (Ptr)NULL, (WindowPtr)-1 );
  43.     if ( !optDlg )
  44.         return;
  45.  
  46.     GetDItem( optDlg, kODSendText, &kind, (Handle *) &listHdl, &r );
  47.     GetDItem( optDlg, kODSendTable, &kind, (Handle *) &tblHdl, &r );
  48.     
  49.     /* Set up a user proc to draw the default outline */
  50.  
  51.     GetDItem( optDlg, kODDefUser, &kind, &h, &r );
  52.     
  53.     outlineUPP = NewUserItemProc( OutlineButton );
  54.     if ( !outlineUPP )
  55.         return;                // STUB should report an error 
  56.  
  57.     SetDItem( optDlg, kODDefUser, kind, (Handle)outlineUPP, &r );
  58.     
  59.     sendByList = (*prefHdl)->sendByList;
  60.     
  61.     if ( sendByList )
  62.         SetCtlValue( listHdl, 1 );
  63.     else
  64.         SetCtlValue( tblHdl, 1 );
  65.  
  66.     do {
  67.         ModalDialog( (ModalFilterUPP)NULL, &item );
  68.         
  69.         switch ( item ){
  70.             case kODSendText:
  71.                 sendByList = true;
  72.                 SetCtlValue( listHdl, 1 );
  73.                 SetCtlValue( tblHdl, 0 );
  74.                 break;
  75.             case kODSendTable:
  76.                 sendByList = false;
  77.                 SetCtlValue( listHdl, 0 );
  78.                 SetCtlValue( tblHdl, 1 );
  79.                 break;
  80.         }
  81.     } while ( item != kODCancel && item != kODOk );
  82.  
  83. #ifdef GENERATINGCFM
  84.     DisposeRoutineDescriptor( outlineUPP );
  85. #endif
  86.     
  87.     if ( item == kODCancel ){
  88.         DisposDialog( optDlg );
  89.         return;
  90.     }
  91.     
  92.     (*prefHdl)->sendByList = sendByList;
  93.  
  94.     ChangedResource( (Handle) prefHdl );
  95.     WriteResource( (Handle) prefHdl );
  96.     
  97.     DisposDialog( optDlg );
  98.     
  99.     return;
  100. }